package leader.action;

import leader.service.DirectLeaderService;
import teacher.bean.Teacher;

import com.opensymphony.xwork2.ActionContext;

public class UpdatePasswordAction {
	private String oldpassword;
	private String newpassword1;
	private String newpassword2;
	private String flag;
	public String getOldpassword() {
		return oldpassword;
	}
	public void setOldpassword(String oldpassword) {
		this.oldpassword = oldpassword;
	}
	public String getNewpassword1() {
		return newpassword1;
	}
	public void setNewpassword1(String newpassword1) {
		this.newpassword1 = newpassword1;
	}
	public String getNewpassword2() {
		return newpassword2;
	}
	public void setNewpassword2(String newpassword2) {
		this.newpassword2 = newpassword2;
	}
	public String getFlag() {
		return flag;
	}
	public void setFlag(String flag) {
		this.flag = flag;
	}
	public String execute() {
		System.out.println("===============密码修改=============");
		Teacher teacher=(Teacher) ActionContext.getContext().getSession().get("leader");
		if(oldpassword.equals(teacher.getPassword())) {
			if(newpassword1.equals(newpassword2)) {
				DirectLeaderService LS = new DirectLeaderService();
				teacher.setPassword(newpassword1);
				LS.updateLeaderPassword(teacher);
				flag="success";
				System.out.println("===============密码修改结束=============");
				
			} else {
				flag="errorone";
				System.out.println("===============确认密码有误=============");
			}
			} else {
				flag="errortwo";
				System.out.println("===============输入旧密码有误=============");
			}
		return "success";
	}
}
